-- for CCLuaEngine traceback
function __G__TRACKBACK__(msg)
    print("----------------------------------------")
    print("LUA ERROR: " .. tostring(msg) .. "\n")
    print(debug.traceback())
    print("----------------------------------------")
end
require "lua/logo"

require "lua/gamefunc"
require "lua/gameSound"
require "lua/lightning"
require "lua/commfunc"
require "lua/gameNumber"

require "lua/gres"

--require "lua/ui_loadinit"
--require "lua/game_loading"
require "lua/loadres"
require "lua/dui_dialog"
require "lua/ui_win"

require "lua/helper"
require "lua/ui_main"
require "lua/ui_begin"
require "lua/ui_select_zjwg"
require "lua/ui_hlws_game"
require "lua/ui_sjsk_game"
require "lua/ui_tjss_game"
require "lua/ui_tjwj_game"
require "lua/ui_role"
require "lua/ui_shop"
require "lua/ui_achieve"

require "lua/ui_roleShow"

require "lua/ui_tutorial"

require "lua/class_GameItemBtn"

require "lua/ui_puz"

require "lua/t_statis"

require "lua/d_role"
require "lua/d_stage"
require "lua/d_achieve"
require "lua/d_shop"
require "lua/d_skills"
--require "lua/d_monster"

local function main()
    -- avoid memory leak
    collectgarbage("setpause", 100)
    collectgarbage("setstepmul", 5000)
    
    ---------------
    local scene, uiid = nil,nil
    if GLOGO == 0 then
        scene, uiid = createLoading()
    else
        scene, uiid = runGameLogo()
    end
    ShowSceneLayer = scene
    CCDirector:sharedDirector():runWithScene(scene)
    
    --注册全局回调
    registerDidEnterBackGroundHandler(GameDidEnterBackGround)
    registerWillEnterBackGroundHandler(GameWillEnterBackGround)
    registerJavaHandler(GameJavaHandler)
end

xpcall(main, __G__TRACKBACK__)

